public  send_sms

ss6      segment     code
rseg    ss6

extrn   code(serial_send)



str_loca_sms    equ     33h
counter1        equ     49h
bai_c           equ     3dh
sh_c            equ     3eh
g_c             equ     3fh


;-------------------------------------------------
;Name of Subprogram: delay3ms
;Function:3 ms delay
;input:None
;output:None
;Effects: The values of R1 and R2
;-------------------------------------------------

delay3ms:
        mov     r1,#15
dl3_pa:
        mov     r2,#100
        djnz    r2,$
        djnz    r1,dl3_pa
        ret

;------------------------------------------------

;-------------------------------------------------------
;Name of Subprogram: delay105ms
;Function:Delay 105 ms
;input: R3
;output: None
;Effects: R1,R2,R3 
;------------------------------------------------------- 
delay105ms:
        
        mov     r3,#23h

cycle4:
        call    delay3ms
        djnz    r3,cycle4
       
        ret
;-------------------------------------------------------

send_sms:          

        mov     counter1,#05h
        mov     dptr,#table13
        lcall   send
        lcall   delay105ms
        lcall   delay105ms
        lcall   delay105ms

        mov     counter1,#0bh
        mov     dptr,#table14
        lcall   send
        lcall   delay105ms
        lcall   delay105ms
        lcall   delay105ms

        mov     counter1,#0dh
        mov     dptr,#table15
        lcall   send
        lcall   delay105ms
        lcall   delay105ms
        lcall   delay105ms

        mov     counter1,#14h
        mov     dptr,#table16
        lcall   send
        lcall   delay105ms
        lcall   delay105ms
        lcall   delay105ms
        
        mov     counter1,#13h
        mov     dptr,#table17
        lcall   send
        

        mov     counter1,#02h
        mov     dptr,#table19
        lcall   send
        lcall   delay105ms
        lcall   delay105ms
        lcall   delay105ms

 
        mov     counter1,#0bh
        mov     dptr,#table7
        lcall   send
        mov     counter1,#19h
        call    send_location

        
        call    send_temper
        mov     a,#1ah
        lcall   serial_send
        lcall   delay105ms
        lcall   delay105ms
        lcall   delay105ms


       

        ret
;-----------------------------------------------------





;-----------------------------------------------------
send_location:
    push    0
    push    acc
    mov     r0,str_loca_sms
loop0_send_location:
    movx    a,@r0
    inc     r0
    call    serial_send
    call    delay3ms
    djnz    counter1,loop0_send_location
exit_send_location:
    pop     acc
    pop     0
    ret
;-----------------------------------------------------


;-----------------------------------------------------
send_temper:
    push    acc

    mov     counter1,#09h
    mov     dptr,#table6
    lcall   send


    mov     a,bai_c
    call    serial_send
    call    delay3ms

    mov     a,sh_c
    call    serial_send
    call    delay3ms

    mov     a,#2eh                    ;2e='.'
    call    serial_send
    call    delay3ms

    mov     a,g_c
    call    serial_send
    call    delay3ms

    mov     a,#43h
    call    serial_send
    call    delay3ms


    
exit_send_temper:
    pop     acc
   
    ret
;-----------------------------------------------------



;-----------------------------------------------------
;Name of Subprogram: send
;Function:send string to serial port
;input:DPTR,counter
;output:None
;Effects: R1,R2
;-----------------------------------------------------
send:
   
    
cycle7:
    mov     a,#00h
    movc    a,@a+dptr

    lcall    serial_send
    lcall    delay3ms
    inc     dptr
    djnz    counter1,cycle7
    
    
    ret
;-----------------------------------------------------


table6:     db      0ah,"Local T:",00h
table7:     db      0ah,"Location:",0ah
table13:    db      0ah,"AT",0dh,0ah
table14:    db      "AT+CMGF=1",0dh,0ah
table15:    db      "AT+CSCS=GSM",0dh,0ah
table16:    db      "AT+CSMP=17,167,0,0",0dh,0ah
table17:    db      "AT+CMGS=89030944159"
table18:    db      "Hello World!",1ah
table19:    db      0dh,0ah

end





